Skip to content

Fix Swift codegen: optional chaining, reserved keywords, redundant public#32

Merged
joaoffcosta merged 3 commits into
mainfrom
joao/fix-optional-chaining-swift-properties
May 26, 2026
Merged

Fix Swift codegen: optional chaining, reserved keywords, redundant public#32
joaoffcosta merged 3 commits into
mainfrom
joao/fix-optional-chaining-swift-properties

Conversation

@joaoffcosta

Copy link
Copy Markdown
Member

Summary

  • Optional chaining: Property value expressions for optional enum types now emit value?.rawValue instead of value.rawValue, fixing a Swift compilation error
  • Reserved keywords: Enum case names that are Swift reserved keywords (e.g. default) are now escaped with backticks
  • Redundant public modifier: Removed public from enum Destination inside public extension, eliminating the Swift compiler warning

Test plan

  • Added optional enum property (ReverseTrialType?) to people_properties spec — verifies value?.rawValue
  • Added "default" enum value to special_property_enums spec — verifies backtick escaping
  • Updated swift_public destinations spec — verifies no redundant public modifier
  • All 67 tests pass

🤖 Generated with Claude Code

joaoffcosta and others added 3 commits May 26, 2026 15:36
When a people property has an optional enum type (e.g. ReverseTrialType?),
the generated Swift code emitted `value.rawValue` instead of `value?.rawValue`,
causing a compilation error. Pass `is_optional` through to the template so it
can emit the `?` for optional chaining.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When an enum value like "default" is camelized, the generated Swift code
emits `case default = "default"` which is a parse error since `default`
is a reserved keyword. Wrap such names in backticks to produce valid Swift.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The `public` on `enum Destination` is redundant when declared inside a
`public extension` — Swift warns about this. Other templates (events,
people_properties) don't add it to their inner types either.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@joaoffcosta joaoffcosta merged commit 67a5a35 into main May 26, 2026
3 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant